package com.ganzalang.gmall.designpatterns.facade;

import lombok.extern.slf4j.Slf4j;

/**
 * @description: 使用外观模式
 * @author: ganzalang
 */
@Slf4j
public class FacadePatternDemo {

    public static void main(String[] args) {
        SystemFacade systemFacade = new SystemFacade();
        systemFacade.execute();
    }

    public interface ServiceA {
        void execute();
    }

    public interface ServiceB {
        void execute();
    }

    public interface ServiceC {
        void execute();
    }

    public interface ModuleFacade {
        void execute();
    }

    public static class SystemFacade implements ModuleFacade {

        @Override
        public void execute() {
            ServiceA serviceA = new ServiceAImpl();
            ServiceB serviceB = new ServiceBImpl();
            ServiceC serviceC = new ServiceCImpl();
            serviceA.execute();
            serviceB.execute();
            serviceC.execute();
        }
    }

    public static class ServiceAImpl implements ServiceA {

        @Override
        public void execute() {
            log.info("执行A模块");
        }
    }

    public static class ServiceBImpl implements ServiceB {

        @Override
        public void execute() {
            log.info("执行B模块");
        }
    }

    public static class ServiceCImpl implements ServiceC {

        @Override
        public void execute() {
            log.info("执行C模块");
        }
    }
}
